{% extends "base.html" %}
{% block title %}集群服务状态{% endblock %}
{% block headpre %}
{% endblock %}
{% block head %}
{% endblock %}
{% block contentheader %}集群服务{% endblock %}
{% block contentsmallheader %}hbase、hive、yarn、oozie、zookeeper等服务状态{% endblock %}
{% block content %}
    <div class="row">
        <div class="col-md-6">
            <div class="box box-primary" id="yarn">
                <div class="box-header with-border">
                    <h3 class="box-title">YARN</h3>
                    <a href="http://172.19.100.12:7180/cmf/services/8/status"><i class="fa fa-share"></i></a>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <ul class="nav nav-pills nav-stacked" id="yarn_list">
                    </ul>
                </div>
            </div>
            <div class="box box-primary" id="hbase">
                <div class="box-header with-border">
                    <h3 class="box-title">HBASE</h3>
                     <a href="http://172.19.100.12:7180/cmf/services/10/status"><i class="fa fa-share"></i></a>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <ul class="nav nav-pills nav-stacked" id="hbase_list">
                    </ul>
                </div>
            </div>
            <div class="box box-primary" id="oozie">
                <div class="box-header with-border">
                    <h3 class="box-title">Oozie</h3>
                     <a href="http://172.19.100.12:7180/cmf/services/18/status"><i class="fa fa-share"></i></a>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <ul class="nav nav-pills nav-stacked" id="oozie_list">
                    </ul>
                </div>
            </div>
            <div class="box box-primary" id="zk">
                <div class="box-header with-border">
                    <h3 class="box-title">Zookeeper</h3>
                     <a href="http://172.19.100.12:7180/cmf/services/4/status"><i class="fa fa-share"></i></a>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <ul class="nav nav-pills nav-stacked" id="zk_list">
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="box box-primary" id="hive">
                <div class="box-header with-border">
                    <h3 class="box-title">Hive</h3>
                     <a href="http://172.19.100.12:7180/cmf/services/12/status"><i class="fa fa-share"></i></a>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <ul class="nav nav-pills nav-stacked" id="hive_list">
                    </ul>
                </div>
            </div>
            <div class="box box-primary" id="hdfs">
                <div class="box-header with-border">
                    <h3 class="box-title">HDFS</h3>
                     <a href="http://172.19.100.12:7180/cmf/services/6/status"><i class="fa fa-share"></i></a>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <ul class="nav nav-pills nav-stacked" id="hdfs_list">
                    </ul>
                </div>
            </div>
            <div class="box box-primary" id="kafka">
                <div class="box-header with-border">
                    <h3 class="box-title">Kafka</h3>
                     <a href="http://172.19.100.12:7180/cmf/services/16/status"><i class="fa fa-share"></i></a>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <ul class="nav nav-pills nav-stacked" id="kafka_list">
                    </ul>
                </div>
            </div>
        </div>


    </div>
{% endblock %}
{% block script %}
    <script>
        function add_class() {
            $('#treeview5').addClass('active');
            $('#menu5').addClass('menu-open');
            $('#monitorclouderaservices').addClass('active');
        }
        $.ajax({
            url: '/monitor_cloudera_services_data',
            success: function (result) {
                var yarn_ = result.yarn_;
                var hdfs_ = result.hdfs_;
                var hbase_ = result.hbase_;
                var hive_ = result.hive_;
                var kafka_ = result.kafka_;
                var zk_ = result.zk_;
                var oozie_ = result.oozie_;
                for (var key in hdfs_) {
                    var info = '';
                    for (var title in hdfs_[key]) {
                        if (title.indexOf('GOOD') > -1)
                            info += "<span class='label label-primary pull-right'>" + hdfs_[key][title] + " " + title + " </span><span class='pull-right'>&nbsp;</span>";
                        else
                            info += "<span class='label label-danger pull-right'>" + hdfs_[key][title] + " " + title + "</span><span class='pull-right'>&nbsp;</span>";
                    }
                    $("#hdfs_list").append("<li><a><i class='fa fa-tasks'></i> " + key + info + "</a></li>");
                }
                for (var key in yarn_) {
                    var info = '';
                    for (var title in yarn_[key]) {
                        if (title.indexOf('GOOD') > -1)
                            info += "<span class='label label-primary pull-right'>" + yarn_[key][title] + " " + title + " </span><span class='pull-right'>&nbsp;</span>";
                        else
                            info += "<span class='label label-danger pull-right'>" + yarn_[key][title] + " " + title + "</span><span class='pull-right'>&nbsp;</span>";
                    }
                    $("#yarn_list").append("<li><a><i class='fa fa-tasks'></i> " + key + info + "</a></li>");
                }
                for (var key in hbase_) {
                    var info = '';
                    for (var title in hbase_[key]) {
                        if (title.indexOf('GOOD') > -1)
                            info += "<span class='label label-primary pull-right'>" + hbase_[key][title] + " " + title + " </span><span class='pull-right'>&nbsp;</span>";
                        else
                            info += "<span class='label label-danger pull-right'>" + hbase_[key][title] + " " + title + "</span><span class='pull-right'>&nbsp;</span>";
                    }
                    $("#hbase_list").append("<li><a><i class='fa fa-tasks'></i> " + key + info + "</a></li>");
                }
                for (var key in hive_) {
                    var info = '';
                    for (var title in hive_[key]) {
                        if (title.indexOf('GOOD') > -1)
                            info += "<span class='label label-primary pull-right'>" + hive_[key][title] + " " + title + " </span><span class='pull-right'>&nbsp;</span>";
                        else
                            info += "<span class='label label-danger pull-right'>" + hive_[key][title] + " " + title + "</span><span class='pull-right'>&nbsp;</span>";
                    }
                    $("#hive_list").append("<li><a><i class='fa fa-tasks'></i> " + key + info + "</a></li>");
                }
                for (var key in kafka_) {
                    var info = '';
                    for (var title in kafka_[key]) {
                        if (title.indexOf('GOOD') > -1)
                            info += "<span class='label label-primary pull-right'>" + kafka_[key][title] + " " + title + " </span><span class='pull-right'>&nbsp;</span>";
                        else
                            info += "<span class='label label-danger pull-right'>" + kafka_[key][title] + " " + title + "</span><span class='pull-right'>&nbsp;</span>";
                    }
                    $("#kafka_list").append("<li><a><i class='fa fa-tasks'></i> " + key + info + "</a></li>");
                }
                for (var key in zk_) {
                    var info = '';
                    for (var title in zk_[key]) {
                        if (title.indexOf('GOOD') > -1)
                            info += "<span class='label label-primary pull-right'>" + zk_[key][title] + " " + title + " </span><span class='pull-right'>&nbsp;</span>";
                        else
                            info += "<span class='label label-danger pull-right'>" + zk_[key][title] + " " + title + "</span><span class='pull-right'>&nbsp;</span>";
                    }
                    $("#zk_list").append("<li><a><i class='fa fa-tasks'></i> " + key + info + "</a></li>");
                }
                for (var key in oozie_) {
                    var info = '';
                    for (var title in oozie_[key]) {
                        if (title.indexOf('GOOD') > -1)
                            info += "<span class='label label-primary pull-right'>" + oozie_[key][title] + " " + title + " </span><span class='pull-right'>&nbsp;</span>";
                        else
                            info += "<span class='label label-danger pull-right'>" + oozie_[key][title] + " " + title + "</span><span class='pull-right'>&nbsp;</span>";
                    }
                    $("#oozie_list").append("<li><a><i class='fa fa-tasks'></i> " + key + info + "</a></li>");
                }
            }
        })
    </script>
{% endblock %}